package com.chen10.cattle.service.impl;

import com.chen10.cattle.mapper.FinanceMapper;
import com.chen10.cattle.model.pojo.OtherFinanceRecord;
import com.chen10.cattle.service.FinanceService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * 财务管理相关服务实现
 */
@Service
public class FinanceServiceImpl implements FinanceService {
    @Resource
    private FinanceMapper financeMapper;

    @Override
    public OtherFinanceRecord addOtherFinanceRecord(OtherFinanceRecord record) {
        record.setCreatedAt(new Date());
        financeMapper.insertOtherFinanceRecord(record);
        return record;
    }

    @Override
    public boolean deleteOtherFinanceRecord(Integer id) {
        return financeMapper.deleteOtherFinanceRecord(id) > 0;
    }

    @Override
    public List<OtherFinanceRecord> getAllOtherFinanceRecords() {
        List<OtherFinanceRecord> records = financeMapper.selectAllOtherFinanceRecords();
        return records;
    }
}